You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): follow-ups whose results share one wake run both settle - #39220
When two follow-ups sent to the same delegated subagent both finished in one child turn (for example, one follow-up's completion notice was steered into the other's wake run), only the first was marked completed. The second stayed running forever with its result undelivered, so the parent kept listing it as background work. The server now settles each task from that shared run and delivers both results to the parent.
On origin/main 8d5e0b2 I wrote a test in apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts ('subagent follow-ups' > 'settles both follow-ups whose subagents' results share one wake'). It runs the real OrchestratorV2, EventSink, projections and recoverDelegatedTasks, the same pattern as the existing 'holds a follow-up open while the child's own subagent still runs'. Steps: (1) seed a parent with a completed async delegated child; (2) dispatch follow-up A to the child; it records a running nested subagent and its run completes; (3) dispatch follow-up B the same way; (4) B's nested subagent completes and opens an untagged wake run, whose user message has delegatedCompletion.parentRunId = B's run; (5) A's nested subagent completes, and its notice is written into the same running wake run (the steer); (6) the wake writes an assistant reply and completes. Observed: A's task is 'completed' with the wake's reply, and B's task stays 'running' with result null (assertion: 'follow-up ...:ordinal:3 never settled: expected running to equal completed'). Disabling only the existingResultTransfer early return in finalizeAppOwnedSubagentTask makes the test pass, which confirms that guard skips B. Not run with a live provider: it needs Codex automatically steering a delegated completion, and this VM has no ChatGPT OAuth.
Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts -t "share one wake" on the repro branch before the fix: failed (follow-up ordinal 3 stayed running)
vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts after the fix: 67 passed
vp test run src/orchestration-v2/RemoteDelegatedTask.test.ts src/orchestration-v2/RestartBackgroundNote.test.ts src/orchestration-v2/RestartContinuation.test.ts src/orchestration-v2/SubagentProjection.test.ts: 76 passed
vp test run src/mcp/OrchestratorMcpService.test.ts src/orchestration-v2/ThreadStop.test.ts src/orchestration-v2/ProjectionRecovery.test.ts src/mcp/OrchestratorMcpToolkit.integration.test.ts: 167 passed
vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (5 files, 103 tests) all passed
Not in this change
The batch loop in finalizeAppOwnedSubagent skips a task with a result if the child has any subagent_result transfer to the parent, not one for that task; settled tasks are the only ones it skips, so it does not cause this bug and I left it alone.
Not verified with a live provider: steering a delegated completion into a running wake needs Codex with ChatGPT OAuth, which the VM does not have.
Who did the work
Written by Claude Opus 5.5, in Claude Code
Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
Reproduces #39204: the second follow-up stays running because the
finalizer finds the first one's result transfer from the shared wake.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The finalizer took any subagent_result transfer from the result run as
proof the task had settled. Two follow-ups can share a wake run, so the
second one never settled. Count the transfer only once the task holds
its result.
Fixes#39204
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No actionable comments were generated in the recent review.
Walkthrough
The finalizer now requires both a non-null task result and a matching result transfer before it skips settlement. A regression test covers two delegated follow-ups whose grandchildren results are acknowledged by one untagged wake run.
Changes: Shared wake completion
Layer / File(s)
Summary
Finalizer guard and shared-wake regression apps/server/src/orchestration-v2/Orchestrator.ts, apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts
The finalizer skips settlement only when the task has a result and a matching transfer. The test verifies that recovery completes both follow-up tasks with the shared wake result.
This change lets two delegated follow-ups that share one wake run both settle and receive their results, as intended. No concrete merge-blocking defect was established. How MCP result retrieval handles the shared transfers was not fully confirmed, but the available evidence does not show a failure.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix and its scope: follow-ups whose results share one wake run now both settle. The Orchestrator.ts change to finalizeAppOwnedSubagentTask and the new regression test both match th…
Description check
The description follows the template well. It has a problem statement, a change explanation, a linked issue (fixes #39204), a reproduction, and a detailed verification section with foc…
Linked Issues check
Issue #39204 requires that two follow-ups whose results share one wake run both settle, and that both results reach the parent. The PR changes finalizeAppOwnedSubagentTask in Orchestrator.ts so an exi…
Out of Scope Changes check
The PR changes two files per the raw summary: a regression test in DelegatedCompletionDelivery.test.ts (+207 lines) and the finalizeAppOwnedSubagentTask guard in Orchestrator.ts (+13/-11). Both direct…
Full details: Title check
Explanation
The title names the fix and its scope: follow-ups whose results share one wake run now both settle. The Orchestrator.ts change to finalizeAppOwnedSubagentTask and the new regression test both match this. The title is specific and follows the conventional commit form. It is not vague, and it does not describe anything absent from the changeset.
Full details: Description check
Explanation
The description follows the template well. It has a problem statement, a change explanation, a linked issue (fixes #39204), a reproduction, and a detailed verification section with focused test commands and observed results. Two gaps remain. The Scope section does not explain the bug in a self-contained way beyond the linked issue, and the Evidence section is an unfilled placeholder that says it must be completed before merge. Under the template, UI screenshots are not required because this is a server-side fix, so the placeholder is the main missing item.
Resolution
Remove or complete the Evidence placeholder. It states that before and after proof is pending and that it must be filled in before merge. For a server-only fix with no UI change, state that no UI evidence applies, or add the captured before and after output. Consider stating in the Scope section that the bug is tracked by issue #39204.
Full details: Linked Issues check
Explanation
Issue #39204 requires that two follow-ups whose results share one wake run both settle, and that both results reach the parent. The PR changes finalizeAppOwnedSubagentTask in Orchestrator.ts so an existing result transfer ends finalization only when the task already has a non-null result. Per the PR description and the raw summary, the regression test 'settles both follow-ups whose subagents' results share one wake' in DelegatedCompletionDelivery.test.ts reproduces the bug on the base commit (follow-up ordinal 3 stayed running) and passes after the change (67 tests in the file pass). The issue's suggested mechanism (targetTaskId on transfers and task-level deduplication in the MCP result lookup) is not adopted. That mechanism is a suggested local fix, not a stated requirement, and the issue's observable requirements are met by the guard change. Limits: the repository diff could not be read (changed blobs missing from the checkout), so the code change is assessed from the PR description and raw summary, not from the source. The live-provider steering path is not verified, as the PR states.
Full details: Out of Scope Changes check
Explanation
The PR changes two files per the raw summary: a regression test in DelegatedCompletionDelivery.test.ts (+207 lines) and the finalizeAppOwnedSubagentTask guard in Orchestrator.ts (+13/-11). Both directly serve issue #39204. The PR text states that the batch-loop behavior in finalizeAppOwnedSubagent is left unchanged, so no unrelated change is introduced. Limits: the repository diff could not be read, so the line-level content of Orchestrator.ts was not checked. The assessment relies on the summary and PR description.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
The automated pipeline stopped on this pull request and will not merge it:
the fix is written and reviewed, but proving it needs something no worker has:
Permanent blocker: The specified reproduction requires Codex automatically steering a delegated completion into an existing running wake and a signed-in ChatGPT OAuth account, which the brief lists as unavailable on every VM. Replay lacks active steering and cannot reproduce that sequence. Both completion settlement and delivery to the parent remain unverified on base and head.
It stays open for a person to finish or close.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:S10-29 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When two follow-ups sent to the same delegated subagent both finished in one child turn (for example, one follow-up's completion notice was steered into the other's wake run), only the first was marked completed. The second stayed running forever with its result undelivered, so the parent kept listing it as background work. The server now settles each task from that shared run and delivers both results to the parent.
Fixes #39204
Reproduction on main
On origin/main 8d5e0b2 I wrote a test in apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts ('subagent follow-ups' > 'settles both follow-ups whose subagents' results share one wake'). It runs the real OrchestratorV2, EventSink, projections and recoverDelegatedTasks, the same pattern as the existing 'holds a follow-up open while the child's own subagent still runs'. Steps: (1) seed a parent with a completed async delegated child; (2) dispatch follow-up A to the child; it records a running nested subagent and its run completes; (3) dispatch follow-up B the same way; (4) B's nested subagent completes and opens an untagged wake run, whose user message has delegatedCompletion.parentRunId = B's run; (5) A's nested subagent completes, and its notice is written into the same running wake run (the steer); (6) the wake writes an assistant reply and completes. Observed: A's task is 'completed' with the wake's reply, and B's task stays 'running' with result null (assertion: 'follow-up ...:ordinal:3 never settled: expected running to equal completed'). Disabling only the existingResultTransfer early return in finalizeAppOwnedSubagentTask makes the test pass, which confirms that guard skips B. Not run with a live provider: it needs Codex automatically steering a delegated completion, and this VM has no ChatGPT OAuth.
Evidence
Being captured: before and after in the real app. This section is filled in before the pull request can merge.
Tests
vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts -t "share one wake"on the repro branch before the fix: failed (follow-up ordinal 3 stayedrunning)vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.tsafter the fix: 67 passedvp test run src/orchestration-v2/RemoteDelegatedTask.test.ts src/orchestration-v2/RestartBackgroundNote.test.ts src/orchestration-v2/RestartContinuation.test.ts src/orchestration-v2/SubagentProjection.test.ts: 76 passedvp test run src/mcp/OrchestratorMcpService.test.ts src/orchestration-v2/ThreadStop.test.ts src/orchestration-v2/ProjectionRecovery.test.ts src/mcp/OrchestratorMcpToolkit.integration.test.ts: 167 passedvp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (5 files, 103 tests) all passedNot in this change
Who did the work
Run by the t3code factory in T3 Code.